#include "wuMossaicManager.h"

wuMossaicManager::wuMossaicManager()
{

}

wuMossaicManager::~wuMossaicManager()
{
}

/*
void wuMossaicManager::setup(ofxBox2d * _box2d, int _vw, int _vh)
{
	wuBase2dManager::setup(_box2d, _vw, _vh);
}
*/
void wuMossaicManager::setPhysics(float _density, float _bounce, float _friction)
{
}

void wuMossaicManager::addBitxo(ofImage *_skin, ofRectangle rect, vector <ofPoint> * _pts)
{

	wuMossaic massive;
	massive.setup(box2d, _skin, rect, _pts);
	mossaics.push_back(massive);
}
void wuMossaicManager::update()
{
        for (int i = 0; i < mossaics.size(); i++)
            mossaics[i].update();
}

void wuMossaicManager::draw(bool bDrawlines, int offX)
{
        for (int i = 0; i < mossaics.size(); i++)
            mossaics[i].draw(bDrawlines, offX);
}

void wuMossaicManager::drawSelected(bool bDrawlines, int offX)
{
    if(selection.width < vw || selection.height < vh)
    {
        for (int i = mossaics.size()-1; i >= 0; i--)
            mossaics[i].drawSelected(bDrawlines, offX, selection);

    }else
    {
        for (int i = 0; i < mossaics.size(); i++)
            mossaics[i].draw(bDrawlines, offX);
    }
}

void wuMossaicManager::clear()
{

    if(selection.width < vw || selection.height < vh)
    {
        for (int i = mossaics.size()-1; i >= 0; i--)
            mossaics[i].clear(selection);

    }else
    {
        for (int i = 0; i < mossaics.size(); i++)
            mossaics[i].clear();
        mossaics.clear();
    }
}

void wuMossaicManager::touch(int _x,int _y, int forceX, int forceY)
{
   for (int i = 0; i < mossaics.size(); i++)
		mossaics[i].touch(_x, _y, forceX, forceY);
}

void wuMossaicManager::desintegration(bool _des)
{
   for (int i = 0; i < mossaics.size(); i++)
		mossaics[i].desintegration(_des);
}

vector <ofPoint> wuMossaicManager::getPosition()
{
    vector <ofPoint> positions;

//   for (int i = 0; i < mossaics.size(); i++)
//       positions.push_back(triangles[i].getPosition());
    if (mossaics.size() >0)
        positions = mossaics[0].getPosition();

    return positions;
}

void wuMossaicManager::setPosition(vector <ofPoint> positions)
{

//   for (int i = 0; i < mossaics.size(); i++)
//        for (int j = 0; j < mossaics.size(); i++)
//            triangles[i].setPosition(positions[i]);
    if (mossaics.size() >0)
        mossaics[0].setPosition(positions);

}

void wuMossaicManager::stop_gravity()
{
//   for (int i = 0; i < mossaics.size(); i++)
    if (mossaics.size() >0)
        mossaics[0].stop_gravity();
}

